$(document).ready(function(){	
  
  Handlebars.registerHelper('formatNumber', function(num, options){
    num = num + '';
    return num.replace(/(?=(?!^)(?:\d{3})+(?:\.|$))(\d{3}(\.\d+$)?)/g,',$1');
  });
  
  Handlebars.registerHelper('formatDate', function(val, options){
    if(val==null || val=="")
      return ""
    var date = new Date(val);
    return date.pattern("yyyy-MM-dd");
  });
  
  Handlebars.registerHelper('formatDateTime', function(val, options){
    if(val==null || val=="")
      return ""
    var date = new Date(val);
    return date.pattern("yyyy-MM-dd HH:mm:ss");
  });

	Handlebars.registerHelper("ifCond",function(v1,operator,v2,options) {
			    switch (operator)
			    {
			        case "==":
			            return (v1==v2)?options.fn(this):options.inverse(this);

			        case "!=":
			            return (v1!=v2)?options.fn(this):options.inverse(this);

			        case "===":
			            return (v1===v2)?options.fn(this):options.inverse(this);

			        case "!==":
			            return (v1!==v2)?options.fn(this):options.inverse(this);

			        case "&&":
			            return (v1&&v2)?options.fn(this):options.inverse(this);

			        case "||":
			            return (v1||v2)?options.fn(this):options.inverse(this);

			        case "<":
			            return (v1<v2)?options.fn(this):options.inverse(this);

			        case "<=":
			            return (v1<=v2)?options.fn(this):options.inverse(this);

			        case ">":
			            return (v1>v2)?options.fn(this):options.inverse(this);

			        case ">=":
			         return (v1>=v2)?options.fn(this):options.inverse(this);

			        default:
			            return eval(""+v1+operator+v2)?options.fn(this):options.inverse(this);
			    }
			});
});	